const fs = require('fs');

const path = require('path');

module.exports = (req,res,next) => {
    // process.cwd()
    console.log(req.path);
    let url = path.join(process.cwd(),req.path);
    //判断当前当前路径是否存在
    if(fs.existsSync(url)){
        //1.判断是否是文件夹
        if(fs.statSync(url).isDirectory()){
            let dirList = fs.readdirSync(url); //['a.html','css']
            res.render('index',{
                list:dirList,
                title:'标题'
            })
        }else{
            //文件
            next()
        }
    }else{
        next();
    }
}